package com.younio.local.service;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

/**
 * @author <a href="mailto:1728209643@qq.com">lan</a>
 * @class com.younio.local.service.Toast
 * @date 2019-05-09 15:12
 */
@Slf4j
public class Toast {

    private static boolean isWin;

    static {
        String os = System.getProperty("os.name");
        isWin = os.toLowerCase().contains("win");
    }

    public static void error(String title, String msg) {
        if (isWin) {
            new Thread(() -> {
                try {
                    log.info("====================================================");
                    Runtime.getRuntime().exec("mshta vbscript:msgbox(\"" + msg + "\",0,\"" + title + "\")(window.close)");
                } catch (IOException e) {
                    e.printStackTrace();
                    log.error(e.getMessage());
                }
            }).start();
        }
    }
}
